<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="text" id="wenben">
    <input type="button" id="btn" value=
    "免费获取验证码">
    <script>
    var i=0;
    var text=document.getElementById("wenben");
    var btn=document.getElementById("btn");
        btn.onclick=function(){
        alert("验证码已发送，请等待10s");
        var time=setInterval(function(){
            if(i<=10){
               console.log(i++)
               btn.type=" "  
            }else{
                alert("时间到了，可重新发送");
                btn.type="button"
                clearInterval(time);
            }
        },1000)
    }
    </script>
</body>

</html>